package com.cupk.controller;

import com.cupk.common.PageResult;
import com.cupk.common.Result;
import com.cupk.dto.ProviderListDto;
import com.cupk.dto.StorageDto;
import com.cupk.service.StorageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 名称StorageController
 * 描述库存管理
 *
 * @version 1.0
 * @author:XiongRuiKai
 * @datatime:2023-06-14 15:21
 */
@RestController
@RequestMapping("/storage")
public class StorageController {
    @Autowired
    private StorageService storageService;

    /**
     * 库存管理分页查询
     * @param page 页码
     * @param pageSize 每页返回的数据条目数
     * @param id 物资编号
     * @param name 物资名称
     * @param number 物资库存数量
     * @return
     */
    @GetMapping("/page")
    public Result<PageResult<StorageDto>>
            getStorageDtoQueryResultsWithPaging(
            @RequestParam(defaultValue = "1") int page,
            @RequestParam(defaultValue = "10") int pageSize,
            @RequestParam(required = false) Integer id,
            @RequestParam(required = false) String name,
            @RequestParam(required = false) Integer number
    ){
        PageResult<StorageDto> storageDto =
                storageService.getStoragePage(id, name, number, page, pageSize);
        return Result.success(storageDto,"Success");
    }
}
